package com.software.library_conquer;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

public class Welcome extends Activity {
    private AlphaAnimation start;
    private View view;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //full screen
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        view = View.inflate(this, R.layout.activity_welcome, null);
//        setContentView(R.layout.activity_welcome);
        setContentView(view);
        initData();
    }


    private void initData(){
        start = new AlphaAnimation(0.0f, 1.0f);
        start.setDuration(3000);
//        requestWindowFeature(Window.FEATURE_NO_TITLE);
        start.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                Log.d("cc", "animation start");
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                Log.d("cc", "animation end");
                redirect();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        view.startAnimation(start);
    }

    private void redirect(){
        startActivity(new Intent(getApplicationContext(), LoginActivity.class));
        finish();
    }
}
